<form class="layui-form w700 js-view-webinfo" method="post" action="{:U('Site/saveConfig')}" lay-label-w100>
    <fieldset class="layui-elem-field pr15">
        <legend class="f14 fn">联系信息</legend>
        <div class="pt10">
            <div class="layui-form-item">
                <label class="layui-form-label">单位名称</label>
                <div class="layui-input-block">
                    <input type="text" name="webinfo[name]" value="{$webinfo.name|default=''}" placeholder="请输入单位名称" autocomplete="off" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">联系电话</label>
                <div class="layui-input-block">
                    <input type="text" name="webinfo[telephone]" value="{$webinfo.telephone|default=''}" placeholder="请输入联系电话" autocomplete="off" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">手机号码</label>
                <div class="layui-input-block">
                    <input type="text" name="webinfo[mobile]" value="{$webinfo.mobile|default=''}" placeholder="请输入手机号码" autocomplete="off" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">传真号码</label>
                <div class="layui-input-block">
                    <input type="text" name="webinfo[fax]" value="{$webinfo.fax|default=''}" placeholder="请输入传真号码" autocomplete="off" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">QQ号码</label>
                <div class="layui-input-block">
                    <input type="text" name="webinfo[qq]" value="{$webinfo.qq|default=''}" placeholder="请输入QQ号码" autocomplete="off" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">微信号</label>
                <div class="layui-input-block">
                    <input type="text" name="webinfo[wx]" value="{$webinfo.wx|default=''}" placeholder="请输入微信号" autocomplete="off" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">二维码</label>
                <div class="layui-input-block">
                    {imgspace name="webinfo[qrcode]" value="$webinfo.qrcode|default=''" title="二维码" /}
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">联系邮箱</label>
                <div class="layui-input-block">
                    <input type="text" name="webinfo[email]" value="{$webinfo.email|default=''}" placeholder="请输入联系邮箱" autocomplete="off" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">联系地址</label>
                <div class="layui-input-block">
                    <input type="text" name="webinfo[addr]" value="{$webinfo.addr|default=''}" placeholder="请输入联系地址" autocomplete="off" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">地址坐标</label>
                <div class="layui-input-block flex">
                    <input type="text" name="webinfo[coord]" value="{$webinfo.coord|default=''}" placeholder="设置地址坐标" readonly autocomplete="off" class="layui-input"/>
                    <button class="layui-btn layui-btn-normal js-btn-coord" type="button"><i class="layui-icon">&#xe715;</i>选择坐标点</button>
                </div>
            </div>
        </div>
    </fieldset>
    <fieldset class="layui-elem-field pr15">
        <legend class="f14 fn">第三方代码</legend>
        <div class="pt10">
            <div class="layui-form-item">
                <label class="layui-form-label">电脑PC端</label>
                <div class="layui-input-block flex">
                    <textarea name="webinfo[thirdcode_pc]" placeholder="请输入内容" class="layui-textarea">{$webinfo.thirdcode_pc|default=''}</textarea>
                    <div class="flex-c ml5">
                        <i class="layui-icon layui-icon-tips" lay-tips="代码会放在 &lt;/body&gt; 标签以上（一般用于放置百度商桥代码、站长统计代码、谷歌翻译代码等）"></i>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">手机移动端</label>
                <div class="layui-input-block flex">
                    <textarea name="webinfo[thirdcode_wap]" placeholder="请输入内容" class="layui-textarea">{$webinfo.thirdcode_wap|default=''}</textarea>
                    <div class="flex-c ml5">
                        <i class="layui-icon layui-icon-tips" lay-tips="代码会放在 &lt;/body&gt; 标签以上（一般用于放置百度商桥代码、站长统计代码、谷歌翻译代码等）"></i>
                    </div>
                </div>
            </div>
        </div>
    </fieldset>
    <div class="layui-form-item mt30">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit>确认提交</button>
        </div>
    </div>
</form>
<script>
    (function () {
        var $view = $('.js-view-webinfo'),
            curmaploc = '';
        $('.js-btn-coord', $view).click(function () {
            var $input = $(this).siblings('input'),
                coord = $input.val();
            curmaploc = '';
            $.confirm({
                type: 2,
                title: false,
                shadeClose: true,
                area: ['450px', '540px'],
                msg: 'http://apis.map.qq.com/tools/locpicker?search=1&type=1&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77&referer=myapp' + (coord ? '&coord=' + coord : ''),
                success: function (layero, index) {
                    $('.layui-layer-btn', layero).css('border-top', '1px solid #ddd');
                },
                yes: function (layero, index) {
                    if (!curmaploc) {
                        $.msg('请选择坐标所在的地址！')
                        return false;
                    }
                    $input.val(curmaploc);
                }
            });
        });
        $(window).off('message.map').on('message.map', function (event) {
            var loc = event.originalEvent.data;
            if (loc && loc.module == 'locationPicker') {
                curmaploc = loc.latlng.lat + ',' + loc.latlng.lng;
            }
        });
    })();
</script>